package com.ruyuan.commodity.utils;

import cn.hutool.json.JSONUtil;
import com.ruyuan.commodity.model.goods.vo.SpecValueVO;
import org.apache.commons.lang.StringUtils;
import java.util.List;

/**
 * sku 名称生成工具
 */

public class SkuNameUtil {

    public  static  String createSkuName(String specs) {
        if (StringUtils.isEmpty(specs)) {
            return "";
        }
        List<SpecValueVO> specList  = JSONUtil.toList(specs, SpecValueVO.class);

        StringBuffer skuName = new StringBuffer();
        specList.forEach(specValueVO -> {
            skuName.append("/");
            skuName.append(specValueVO.getSpecValue());
        });
        return skuName.toString().substring(1);
    }

}
